export default (timer, type) => {
    //调用事件构造函数
    let date = new Date(timer);
    //年
    let year = date.getFullYear();
    //月
    //字符串补位的方法 padStart() //字符串头部补位  padEnd() 末尾补位
    let month = (date.getMonth() + 1 + "").padStart("2", "0");
    //日
    let day = (date.getDate() + "").padStart("2", "0");
    //小时
    let hours = (date.getHours() + "").padStart("2", "0");
    //分
    let minutes = (date.getMinutes() + "").padStart("2", "0");
    //秒
    let seconds = (date.getSeconds() + "").padStart("2", "0");
    console.log(day, "日期");
    if (type == "YYYY-MM-DD HH:mm:ss") {
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    } else if (type == "YYYY/MM/DD HH:mm:ss") {
      return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
    } else {
      return `${year}-${month}-${day}`;
    }
  }